home *** CD-ROM | disk | FTP | other *** search
/ Revista do CD-ROM 101 / CD-ROM 101.iso / compl / maya5ple / Install_MayaPLE5_English.exe / Maya / Data1.cab / performExportCharacterMap.me < prev    next >
Encoding:
Text File  |  2003-07-17  |  7.5 KB  |  329 lines

  1. // Copyright (C) 1997-2002 Alias|Wavefront,
  2. // a division of Silicon Graphics Limited.
  3. //
  4. // The information in this file is provided for the exclusive use of the
  5. // licensees of Alias|Wavefront.  Such users have the right to use, modify,
  6. // and incorporate this code into other products for purposes authorized
  7. // by the Alias|Wavefront license agreement, without fee.
  8. //
  9. // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  10. // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
  11. // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  12. // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  13. // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  14. // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  15. // PERFORMANCE OF THIS SOFTWARE.
  16. //
  17. //
  18. //  Alias|Wavefront Script File
  19. //  MODIFY THIS AT YOUR OWN RISK
  20. //
  21. //  Creation Date:  Jan 2, 2000
  22. //  Author:         bb
  23. //
  24. //  Description:
  25. //      This script is the export character map option box dialog.
  26. //
  27. //  Input Arguments:
  28. //      None.
  29. //
  30. //  Return Value:
  31. //      None.
  32. //
  33.  
  34. proc setOptionVars (int $forceFactorySettings)
  35. {
  36.     //    characterMapMethod:
  37.     //    1: by attr name
  38.     //  2: by attr order
  39.     //  3: by node name
  40.     //  4: using existing mapping
  41.     //
  42.     if ( $forceFactorySettings || !`optionVar -exists characterMapMethod`) {
  43.         optionVar -intValue characterMapMethod 3;
  44.     }
  45.  
  46. }
  47.  
  48. //
  49. //  Procedure Name:
  50. //      characterMapSetup
  51. //
  52. //  Description:
  53. //        Update the state of the option box UI to reflect the option values.
  54. //
  55. //  Input Arguments:
  56. //      parent               - Top level parent layout of the option box UI.
  57. //                             Required so that UI object names can be 
  58. //                             successfully resolved.
  59. //
  60. //    forceFactorySettings     - Whether the option values should be set to
  61. //                             default values.
  62. //
  63. //  Return Value:
  64. //      None.
  65. //
  66. global proc characterMapSetup (string $parent, int $forceFactorySettings)
  67. {
  68.     // Retrieve the option settings.
  69.     setOptionVars( $forceFactorySettings );
  70.  
  71.     setParent $parent;
  72.     
  73.     // Set the correct radio button.
  74.     int $whichMethod = `optionVar -query characterMapMethod`;
  75.     switch($whichMethod) {
  76.         case 1:
  77.             radioButtonGrp -e -sl 1 byAttrNameMethod;
  78.             break;
  79.         case 2:
  80.             radioButtonGrp -e -sl 1 byAttrOrderMethod;
  81.             break;
  82.         case 3:
  83.             radioButtonGrp -e -sl 1 byNodeNameMethod;
  84.             break;
  85.         case 4:
  86.             radioButtonGrp -e -sl 1 byCurrentMapMethod;
  87.             break;
  88.         default:
  89.             radioButtonGrp -e -sl 1 byAttrNameMethod;
  90.             break;
  91.     }
  92.  
  93. }
  94.  
  95. //
  96. //  Procedure Name:
  97. //      characterMapCallback
  98. //
  99. //  Description:
  100. //        Update the option values with the current state of the option box UI.
  101. //
  102. //  Input Arguments:
  103. //      parent - Top level parent layout of the option box UI.  Required so
  104. //               that UI object names can be successfully resolved.
  105. //
  106. //    doIt       - Whether the command should execute.
  107. //
  108. //  Return Value:
  109. //      None.
  110. //
  111. global proc characterMapCallback (string $parent, int $doIt)
  112. {
  113.     setParent $parent;
  114.  
  115.     if (`radioButtonGrp -q -sl byAttrNameMethod` == 1) {
  116.         optionVar -intValue characterMapMethod 1;
  117.     } else if (`radioButtonGrp -q -sl byAttrOrderMethod` == 1) {
  118.         optionVar -intValue characterMapMethod 2;
  119.     } else if (`radioButtonGrp -q -sl byCurrentMapMethod` == 1) {
  120.         optionVar -intValue characterMapMethod 4;
  121.     } else {
  122.         optionVar -intValue characterMapMethod 3;
  123.     }
  124.  
  125.     if ($doIt)
  126.         performExportCharacterMap false;
  127. }
  128.  
  129.  
  130. proc string characterMapWidgets( string $parent )
  131. {
  132.     setParent $parent;
  133.     
  134.     string $tabForm = `columnLayout -adj true`;
  135.  
  136.     // how to do the export
  137.     radioButtonGrp -numberOfRadioButtons 1
  138.         -select 1
  139.         -label "Map Method"
  140.         -label1 "By Attribute Name"
  141.         byAttrNameMethod;
  142.  
  143.     radioButtonGrp -numberOfRadioButtons 1
  144.         -label1 "By Attribute Order"
  145.         -shareCollection byAttrNameMethod
  146.         byAttrOrderMethod;
  147.  
  148.     radioButtonGrp -numberOfRadioButtons 1
  149.         -label1 "By Node Name"
  150.         -shareCollection byAttrNameMethod
  151.         byNodeNameMethod;
  152.  
  153.     radioButtonGrp -numberOfRadioButtons 1
  154.         -label1 "By Current Map"
  155.         -shareCollection byAttrNameMethod
  156.         byCurrentMapMethod;
  157.  
  158.     return $tabForm;
  159. }
  160.  
  161. global proc characterMapOptions ()
  162. {
  163.     string $commandName = "characterMap";
  164.  
  165.     // Build the option box "methods"
  166.     //
  167.     string $callback = ($commandName + "Callback");
  168.     string $setup = ($commandName + "Setup");
  169.  
  170.     //    Get the option box.
  171.     //
  172.     //  The value returned is the name of the layout to be used as
  173.     //    the parent for the option box UI.
  174.     //
  175.     string $layout = getOptionBox();
  176.     setParent $layout;
  177.  
  178.     setOptionBoxCommandName("characterMap");
  179.  
  180.     setUITemplate -pushTemplate DefaultTemplate;
  181.     waitCursor -state 1;
  182.     tabLayout -scr true -tv false;    // To get the scroll bars
  183.  
  184.     string $parent = `columnLayout -adjustableColumn 1`;
  185.  
  186.     characterMapWidgets $parent;
  187.  
  188.     waitCursor -state 0;
  189.     setUITemplate -popTemplate;
  190.  
  191.     //    'Apply' button.
  192.     //
  193.     string $applyBtn = getOptionBoxApplyBtn();
  194.     button -edit
  195.         -label "Export"
  196.         -command ($callback + " " + $parent + " " + 1)
  197.         $applyBtn;
  198.  
  199.     //    'Save' button.
  200.     //
  201.     string $saveBtn = getOptionBoxSaveBtn();
  202.     button -edit 
  203.         -command ($callback + " " + $parent + " " + 0 + "; hideOptionBox")
  204.         $saveBtn;
  205.  
  206.     //    'Reset' button.
  207.     //
  208.     string $resetBtn = getOptionBoxResetBtn();
  209.     button -edit 
  210.         -command ($setup + " " + $parent + " " + 1)
  211.         $resetBtn;
  212.  
  213.     //    Set the option box title.
  214.     //
  215.     setOptionBoxTitle("Export Character Map Options");
  216.  
  217.     //    Customize the 'Help' menu item text.
  218.     //
  219.     setOptionBoxHelpTag( "ExportCharacterMap" );
  220.  
  221.     //    Set the current values of the option box.
  222.     //
  223.     eval (($setup + " " + $parent + " " + 0));    
  224.     
  225.     //    Show the option box.
  226.     //
  227.     showOptionBox();
  228. }
  229.  
  230.  
  231. //
  232. //  Procedure Name:
  233. //      assembleCmd
  234. //
  235. //  Description:
  236. //        Construct the command that will apply the option box values.
  237. //
  238. //  Input Arguments:
  239. //      None.
  240. //
  241. //  Return Value:
  242. //      None.
  243. //
  244. proc string assembleCmd()
  245. {
  246.     string $cmd;
  247.  
  248.     setOptionVars(false);
  249.  
  250.     string $mapMethod = "byAttrName";
  251.     int $whichMethod = `optionVar -q characterMapMethod`;
  252.     switch ($whichMethod) {
  253.         case 1:
  254.             $mapMethod = "byAttrName";
  255.             break;
  256.         case 2:
  257.             $mapMethod = "byAttrOrder";
  258.             break;
  259.         case 3:
  260.             $mapMethod = "byNodeName";
  261.             break;
  262.         case 4:
  263.             $mapMethod = "currentMap";
  264.             break;
  265.     }
  266.  
  267.     // doExportCharacterMapArgList takes a string array 
  268.     //
  269.     $cmd =    "doExportCharacterMapArgList 2 { " +
  270.                 "\"" + $mapMethod + "\"" +
  271.             " };";
  272.  
  273.     return $cmd;
  274. }
  275.  
  276. //
  277. //  Procedure Name:
  278. //      performExportCharacterMap
  279. //
  280. //  Description:
  281. //        Post a window with the export character map options or assemble
  282. //        a string corresponding to the character map command.
  283. //        
  284. //
  285. //  Input Arguments:
  286. //      0 - Execute the command.
  287. //      1 - Show the option box dialog.
  288. //      2 - Return the command.
  289. //
  290. //  Return Value:
  291. //      None.
  292. //
  293. global proc string performExportCharacterMap(int $action)
  294. {
  295.     string $cmd = "";
  296.  
  297.     switch ($action) {
  298.  
  299.         //    Execute the command.
  300.         //
  301.         case 0:
  302.             //    Retrieve the option settings
  303.             //
  304.             setOptionVars(false);
  305.  
  306.             //    Get the command.
  307.             //
  308.             $cmd = `assembleCmd`;
  309.  
  310.             //    Execute the command with the option settings.
  311.             //
  312.             if ($cmd != "")
  313.                 evalEcho($cmd);
  314.             break;
  315.  
  316.         //    Show the option box.
  317.         //
  318.         case 1:
  319.             characterMapOptions;
  320.             break;
  321.         case 2:
  322.             //    Get the command.
  323.             //
  324.             $cmd = `assembleCmd`;
  325.     }
  326.     return $cmd;
  327. }
  328.  
  329.